package com.tang.lts.core.nio;

import com.tang.lts.core.nio.channel.ChannelInitializer;
import com.tang.lts.core.nio.config.NioClientConfig;
import com.tang.lts.core.nio.handler.Futures;
import com.tang.lts.core.nio.handler.NioHandler;
import com.tang.lts.core.nio.processor.NioClientProcessor;

import java.net.InetSocketAddress;

/**
 * @author Tang
 * @classname NioClient
 * @description [  ]
 * @date 2022/5/16 15:06
 */
public class NioClient {

    private NioClientProcessor processor;

    public NioClient(NioClientConfig clientConfig, NioHandler eventHandler, ChannelInitializer channelInitializer) {
        this.processor = new NioClientProcessor(clientConfig,eventHandler,channelInitializer);
    }

    public Futures.ConnectFuture connect(InetSocketAddress address) {
        this.processor.start();
        return this.processor.connect(address);
    }
}